package
{
	import com.touchX.display.AbstractDisplay;
	import com.touchX.display.LoaderManager;
	
	import flash.display.Sprite;
	import flash.events.Event;
	
	import webModule.Footer;
	import webModule.Header;
	import webModule.Menu;
	import webModule.Products;
	import webModule.menu.MenuEvent;
	import net.hires.debug.Stats;
	
	[Frame(factoryClass="Preloader")]
	[SWF(backgroundColor="0x1A1A1A",frameRate="50")]
	public class DCWebSite extends AbstractDisplay
	{
		private var loaderManager:LoaderManager;
		
		private var footer:Footer;
		private var header:Header;
		private var menu:Menu;
		private var listUrl:String="../data/productList.xml";
		private var module:AbstractDisplay;
		public function DCWebSite()
		{
			super();
			
		}
		protected override function added(event:Event):void{
			super.added(event);
			loaderManager=LoaderManager.getInstance();
			loaderManager.y=51;
			addChild(loaderManager);
			
			footer=new Footer();
			footer.y=stage.stageHeight-30;
			addChild(footer);
			
			header=new Header();
			addChild(header);
			
			menu=new Menu();
			menu.x=150;
			addChild(menu);
			menu.addEventListener(MenuEvent.MENU_SELECTED,menuSelected);
			
			module=new Products(listUrl);
			addChildAt(module,0);
			
			//addChild(new Stats());
		}
		protected override function resize(event:Event=null):void{
			super.resize(event);
			if(footer) footer.y=stage.stageHeight-30;
		}
		private function menuSelected(evt:MenuEvent):void{
			trace(evt.menuItem.label);
			switch(evt.menuItem.label){
				case "关于我们":
					if(module) module.dispose();
					break;
				case "产品系列":
					if(module) module.dispose();
					module= new Products(listUrl);
					addChildAt(module,0);
					break;
				case "联系我们":
			}
			
		}
		
	}
}